import axios from 'axios'

//登录
interface ILogin{
  grant_type:string,
  client_secret:string,
  client_id:string,
  password:string,
  username:string
}

export const authLogin=(params:ILogin):any=>{
  return axios.post("/webapi/connect/token",params,{
    headers:{
      'Content-Type':'application/x-www-form-urlencoded'
    }
  })
}

//退出登录
export const authLogOut=():any=>{
  return axios.get("/webapi/api/account/logout")
}

//获取用户列表
export const  getUserList=(params:any):any=>{
  return axios.get('/webapi/api/identity/users',{params})
}

//查询用户
export const getUser=(id:string):any=>{
  return axios.get('/webapi/api/identity/users/'+id)
}

//新增用户
interface IaddUser{
  userName: string,
  email: string,
  password: string,
  shouldChangePasswordOnNextLogin:boolean,
  sendConfirmationEmail:boolean,
  isActive:boolean
}
export const addUser=(params:IaddUser):any=>{
     return axios.post('/webapi/api/identity/users',params)
}

//删除用户
export const deleteUser=(id:string):any=>{
  return axios.delete('/webapi/api/identity/users/'+id)
}
interface IeditUser{
  userName: string,
  email: string
}
//修改用户
export const editUser=(id:string,params:IeditUser):any=>{
  return axios.put('/webapi/api/identity/users/'+id,params)
}
